<template>
  <div class="pagination">
    <el-pagination
      v-model:current-page="props.pageNum"
      v-model:page-size="props.pageSize"
      :page-sizes="[10, 20, 50, 100]"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>
<script setup>
// 接受父组件数据
const props = defineProps({
  pageSize: { type: Number, default: 1 },
  pageNum: { type: Number, default: 10 },
  total: { type: Number, default: 0 }
})
const emit = defineEmits(['pageChange'])
const handleSizeChange = (val) => {
  emit('pageChange', { type: 'size', pageNum: props.pageNum, pageSize: val })
}
const handleCurrentChange = (val) => {
  emit('pageChange', { type: 'currentPage', pageNum: val, pageSize: props.pageSize })
}
</script>
<style scoped>
.pagination {
  display: flex;
  justify-content: right;
}
</style>
